import type { Logistics, OrderDetail } from '../types/order'
import type { OrderPre, AddressItem } from '@/types/order'
import { request } from '@/utils/request'

/**
 * 查询药品订单预支付信息
 * @param params
 */
export const getMedicalOrderPre = (params: { prescriptionId: string }) =>
  request<OrderPre>('/patient/medicine/order/pre', 'GET', params)

/**
 * 获取收货地址列表
 */
export const getAddressList = () => request<AddressItem[]>('/patient/order/address')

/**
 * 获取药品订单id
 * @param data
 *  id 处方id
 *  addressId 地址id
 */
export const createMedicalOrder = (data: { id: string; addressId: string }) =>
  request<{ id: string }>(`patient/medicine/order`, 'POST', data)

/**
 *
 */
export const reqGetMedicalOrderDetail = (id: string) =>
  request<OrderDetail>(`/patient/medicine/order/detail/${id}`)

/**
 * 获取药品订单物流信息
 * @param id
 */
export const getMedicalOrderLogistics = (id: string) =>
  request<Logistics>(`/patient/order/${id}/logistics`)
